#define _CRT_SECURE_NO_WARNINGS 1

#include "QUe.h"
void QueueInit(Queue* pq)
{
	assert(pq);
	pq->head = NULL;
	pq->tail = NULL;



}

void QueueDestory(Queue* pq)
{
	assert(pq);

	Node* cur = pq->head;
	while (cur)
	{
		Node* next = cur->next;
		free(cur);
		cur = next;

	}

	pq->head = pq->tail = NULL;


}

void QueuePush(Queue* pq, Type x)
{
	assert(pq);
	Node* new = (Node*)mallco(sizeof(Node));
	if (new == NULL)
	{
		printf("mallco fail\n");
	}
	new->date = x;
	new->next = NULL;
	if (pq->tail = NULL)
	{
		pq->tail = new;
	}


	else
	{
		pq->tail->next = new;
		pq->tail = new;

	}

}


void QueuePop(Queue* pq)
{
	assert(pq);
	assert(pq->head);
	
	if (pq->head->next == NULL)
	{
		free(pq->head);
		pq->head = NULL;
		pq->tail = NULL;
	}


	Node* next = pq->head->next;
	free(pq->head);
	pq->head = next;



}